# encoding: utf-8
# @author: __匸匿
"""
@license: 980980524@qq.com,
@contact: qq:980980524
@file: __init__.py.py
@time: 19-1-2 下午7:44
@desc:
"""
from flask import Flask
from flask_session import Session
from flask_sqlalchemy import SQLAlchemy
from flask_wtf import CSRFProtect
from redis import StrictRedis

from config import config
from info.modules.index import index_blu

db = SQLAlchemy()

def create_app(config_name):
    app = Flask(__name__)
    # 加载配置
    app.config.from_object(config["development"])

    db.init_app(app)

    # 初始化 redis 存储对象
    redis_store = StrictRedis(host=config["development"].REDIS_HOST,port=config["development"].REDIS_PORT)
    # 开启当前项目 CSRF保护 ,只做服务器验证功能
    CSRFProtect(app)
    #设置session保存指定位置
    Session(app)
    app.register_blueprint(index_blu)

    return app